package com.travelsupport.common;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;

import android.graphics.Bitmap;
import android.graphics.BitmapFactory;

public class Common {
	// NTDUC - convert bitmap to byte[]
	public byte[] convertToByte(Bitmap image) {

		// convert bitmap to byte
		ByteArrayOutputStream stream = new ByteArrayOutputStream();
		image.compress(Bitmap.CompressFormat.JPEG, 100, stream);
		byte imageInByte[] = stream.toByteArray();
		return imageInByte;
	}

	// NTDUC - convert byte[] to bitmap
	public Bitmap convertToPictureId(byte[] byteToConvert) {
		byte[] outImage = byteToConvert;
		ByteArrayInputStream imageStream = new ByteArrayInputStream(outImage);
		Bitmap theImage = BitmapFactory.decodeStream(imageStream);
		return theImage;
	}
}
